package com.dartfar.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class DictionaryServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static WebApplicationContext springContext;  

	
    private ServletContext context;  
    
    public void init() throws ServletException {  
    	SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    	springContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext()); 

        DictionaryFactory.servletContext = this.getServletContext();  
          
        context = this.getServletContext();  
        DictionaryFactory dictionaryFactory = new DictionaryFactory();  
        HashMap<String, HashMap> dictMap = (HashMap<String, HashMap>) dictionaryFactory.dictMap;  
        context.setAttribute("dictMap", dictMap);  
        System.out.println(sdf.format(new Date()) +  ",187  INFO [main] DictionaryFactory:18 - Initialize Dictionary Successfully");  
    }  
    
    public DictionaryServlet(){
    	super(); 
    }
    
    public void destroy() {  
        super.destroy(); 
    }

    
    
	
}
